package com.visitorspecials.tankbattle;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import android.content.Context;
import android.graphics.BitmapFactory;
import android.opengl.GLES10;
import android.graphics.*;

public class Particles extends Mesh
{
	private Particle[][] particles;
	
	public Particles(Sprite victim)
	{
		int size = (int) Math.sqrt(victim.getSize());
		particles = new Particle[(int) victim.getSize()][(int) victim.getSize()];
		
		for(int i = 0; i < particles.length;i++)
		{
			for(int k = 0; k < particles[0].length;k++)
			{
				particles[i][k] = new Particle(victim.getTextureName(),(k+1*size)-(size/2),(i+1*size)-(size/2),victim.getHeading(),size);
				this.setCorrectTexture(particles[i][k]);
			}
		}
	}
	
	public void setCorrectTexture(Particle particle)
	{
		float textureCoordinates[] = { 
				.25f, .75f, 
				.75f, .75f, 
				0.25f, 0.25f,
				.75f, 0.25f};
		
		particle.setTextureCoordinates(textureCoordinates);
	}
	
	public void draw(GL10 gl)
	{
		for(int i = 0; i < particles.length;i++)
		{
			for(int k = 0; k < particles[0].length;k++)
			{
				particles[i][k].draw(gl);
			}
		}
		update();
	}
	
	public void update()
	{
		for(int i = 0; i < particles.length;i++)
		{
			for(int k = 0; k < particles[0].length;k++)
			{
				//particles[i][k].update();
			}
		}
	}
}
